Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r.null: added test cases the module #5214

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Shreshth-Malik
Copy link
Contributor

This PR introduces tests for the r.null module to validate its functionality. The tests cover:

Basic Functionality: Verifies that r.null correctly adds null values in the raster map using setnull parameter.
Float Maps: Tests the -f flag for adding null values in the float map.
Fill Nulls: Tests null parameter to replace null values

The tests use temporary regions and custom raster maps.

@github-actions github-actions bot added raster Related to raster data processing Python Related code is in Python module tests Related to Test Suite labels Feb 26, 2025
# Create map1: categories 1, 2, 3 as rows
cls.runModule(
"r.mapcalc",
expression="map_basic = if(row() == 1, 1, if(row() == 2, 2, if(row() == 3, 3, null())))",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be simplified:

map_basic = row()

self.assertModule(module)

# Validate category mappings using r.category
category_output = gs.parse_command("r.describe", map="map_basic", format="json")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using "1" flag here to just list all the values seems better

module = SimpleModule("r.null", map="map2", setnull="1", flags="f")
self.assertModule(module)

category_output = gs.parse_command("r.describe", map="map2", format="json")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here the range flag may be better for the floating point


def test_fill_nulls(self):
"""Verify module fills nulls"""
module = SimpleModule("r.null", map="map_fill_nulls", null="1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not doing much, it would be better if the input had some nulls, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Python Related code is in Python raster Related to raster data processing tests Related to Test Suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants